#include "lab4_problem4.h"

#include <iostream>
#include <string>

#include "../p1/PowerMethod.h"
#include "../../utils/MatrixUtils.h"

namespace Lab4
{
    namespace Problem4
    {
        void problem4()
        {
            std::cout << "Lab 4 - Problem 4:" << std::endl;
        
        	// Get the path of the files to build the matrices.
        	static const std::string filePathA = "lab4/p4/datos/wilkinson_300.txt";
        	static const std::string filePathx0 = "lab4/p4/datos/b.txt"; 
        	
        	static const uint32_t maxIterations = 1000;
        	static const double errorTolerance = 0.001;

        	// Use the power method to approximate the eigenvalue and eigenvector
        	// of the first matrix.
        	double eigenValue = 0.0;
        	static const uint32_t matrixDimension = 300;
        	Utils::Matriz eigenVector(matrixDimension, 1);
        	uint32_t lastIteration = 0;
        	NumericalAnalysis::PowerMethod(matrixDimension, filePathA, filePathx0, maxIterations, errorTolerance, 
        	                               eigenValue, eigenVector, lastIteration);

        	// Resultado = 150.322
        	std::cout << "Eigenvalue = " << eigenValue << std::endl << std::endl;

        	std::cout << "Eigenvector:" << std::endl;
        	
        	// Resultado = 191
        	std::cout << std::endl;
        	std::cout << "Last Iteration = " << lastIteration << std::endl;
        }
    }
}
